<?
if(isset($_POST['submitted']))
{
	$name = trim($_POST['name']);
	$id = trim($_POST['id']);
	$pwd = trim($_POST['pwd']);
	$dept = $_POST['dept'];
	$phone = trim($_POST['phone']);
	if($dept == Manager)
		$adminLevel = "2";
	else	$adminLevel = "3";

	include('db_connect.php');
	$query = "insert into user(userName, userLogInName, userPW, userDept, userPhone, adminLevel) values
					('$name', '$id', SHA1('$pwd'), '$dept', '$phone', '&adminLevel')";
	$result = mysql_query($query);
}
?>

<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

<script type="text/javascript">
<!--
function inputCheck(form)
{
	if(!form.name.value)
	{
		alert("이름을 입력하세요");
		form.name.focus();
		return false;	
	}
	if(!form.id.value)
	{
		alert("아이디를 입력하세요");
		form.id.focus();
		return false;	
	}
	if(!form.pwd.value)
	{
		alert("비밀번호를 입력하세요");
		form.pwd.focus();
		return false;	
	}
	if(!form.pwd2.value)
	{
		alert("비밀번호를 한 번 더입력하세요");
		form.pwd2.focus();
		return false; 
	}
	if(!form.phone.value)
	{
		alert("전화번호를 입력하세요");
		form.phone.focus();
		return false;	
	}
	if(form.pwd.value != form.pwd2.value)
	{
		alert("비밀번호가 일치하지 않습니다");
		form.pwd.value='';
		form.pwd2.value='';
		form.pwd.focus();
		return false;
	}
	return true;
}
//-->
</script>

</head>
<body>
<form method="post" action="signup.php" onsubmit="return inputCheck(this)">

<h><b>PAPYRUS</h></b>
<table>
<tr>
	<td width="110" height="50">이름</td>
	<td width="150" height="50"><input type="text" name="name"></td>
</tr>
<tr>
	<td width="110" height="50">아이디</td>
	<td width="150" height="50"><input type="text" name="id"></td>
</tr>
<tr>
	<td width="110" height="50">비밀번호</td>
	<td width="150" height="50"><input type="password" name="pwd"></td>
</tr>
<tr>
	<td width="110" height="50">비밀번호확인</td>
	<td width="150" height="50"><input type="password" name="pwd2"></td>
</tr>
<tr>
	<td width="110" height="50">부서</td>
	<td width="150" height="50"><select name="dept">
		<option value="R&D" selected> R&D
		<option value="Manager"> Manager
		<option value="Concept Artist"> Concept Artist
		<option value="Modeling"> Modeling
		<option value="Texturing"> Texturing
		<option value="Lighting"> Lighting
		<option value="Rigging"> Rigging
		<option value="FX"> FX
		<option value="Rendering"> Rendering
		<option value="Compositing"> Compositing
	</select></td>
</tr>
<tr>
	<td width="110" height="50">폰번호</td>
	<td width="150" height="50"><input type="text" name="phone"></td>
</tr>
<tr>
	<td align="center" colspan="2"><input type="submit" name="submitted" value="가입하기"></td>
</tr> 
</table>	
</form>
</body>
</html>